<template>
  <div class="home">
    首页
    <h1>用户名{{username}}</h1>
    <h1>手机号{{mobile}}</h1>
    <h1>密码{{password}}</h1>
    <input type="button" @click="exit" value="退出"/>

  </div>
</template>
<script>
import {useStore} from "vuex"
import {ref} from "vue"
import router from '../router';
export default {
  setup(){
    const store = useStore();
    var username = ref(null);
    var mobile = ref(null);
    var password = ref(null);
    var my = ref(JSON.parse(localStorage.getItem('my')))
    var val = store.getters.getmy(my)
    if(!val){
      router.push("/login")
      return;
    }
    username.value=val.username;
    mobile.value=val.mobile;
    password.value=val.password;
    let exit = ()=>{
      localStorage.setItem('my',null)
      router.push("/login")
    }
    return{
      username,
      mobile,
      password,
      exit
    }
  }
}
</script>
